package com.cykj.controller;

import com.cykj.annoation.Log;
import com.cykj.dto.ResponseDTO;
import com.cykj.service.IMenuService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Program: Mooc-Admin
 * @Package: com.cykj.controller
 * @Author: 张俊杰
 * @Create: 2025-07-09 12:29
 * @Description: TODO
 * @Vision: 1.0
 **/
@RestController
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private IMenuService menuService;

    @Operation(summary = "获取菜单")
    @GetMapping("list")
    public ResponseDTO getListMenu(Integer roleId) {
        return menuService.getListMenu(roleId);
    }

    @Operation(summary = "获取未分配的菜单")
    @Log(model = "菜单模块", value = "获取未分配的菜单")
    @GetMapping("assignNot")
    public ResponseDTO getListAssignNot(Integer roleId) {
        return menuService.getListMenuAssignNot(roleId);
    }

    @Operation(summary = "删除菜单权限")
    @Log(model = "菜单模块", value = "删除菜单权限")
    @PostMapping("delete/{roleId}")
    public ResponseDTO removePermission(@PathVariable Integer roleId, @RequestBody List<Integer> menuIds) {

        return menuService.removePermission(roleId, menuIds);
    }

    @Operation(summary = "增加菜单权限")
    @Log(model = "菜单模块", value = "增加菜单权限")
    @PostMapping("add/{roleId}")
    public ResponseDTO addPermission(@PathVariable Integer roleId, @RequestBody List<Integer> menuIds) {
        return menuService.addPermission(roleId, menuIds);
    }
}
